package com.liujun.spring4.demo.aop.ioc.base.applicationContextBeans;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * 对spring工厂定义信息进行后处理,即在所有bean操作之前
 *
 * @author liujun
 * @version 1.0
 * @date 2018-08-15 08:46:00
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
      throws BeansException {

    BeanDefinition bd = beanFactory.getBeanDefinition("car");
    bd.getPropertyValues().addPropertyValue("brand", "奇瑞QQ");
    System.out.println("调用BeanFactoryPostProcessor.postProcessBean Factory()!");
  }
}
